package com.vim.modules.mall.service.remote;

import com.vim.modules.mall.model.base.CommonPage;
import com.vim.modules.mall.model.base.MallResponseEntity;
import com.vim.modules.mall.model.mallGoods.MallGoods;
import com.vim.modules.mall.model.mallGoods.MallGoodsType;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @作者 Administrator
 * @时间 2020-10-04 19:03
 * @版本 1.0
 */
@Service
@FeignClient(name = "web-gateway", contextId = "remoteMallGoodsService", fallback = RemoteMallGoodsServiceFallBack.class)
public interface RemoteMallGoodsService {

    /**
     * 获取商品列表
     * @param pageNo 当前页码
     * @param pageSize 每页数量
     */
    @GetMapping("/adminApi/goods/goodsList")
    MallResponseEntity<CommonPage<MallGoods>> goodsList(
            @RequestParam(value = "goodsName", required = false) String goodsName,
            @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize
    );

    /**
     * 获取商品信息
     * @param id 商品id
     */
    @GetMapping("/adminApi/goods/goodsInfo/{id}")
    MallResponseEntity<MallGoods> goodsInfo(@PathVariable(value = "id") Long id);

    /**
     * 商品保存
     * @param goodsInfo 商品信息json串
     */
    @PostMapping("/adminApi/goods/goodsSave")
    MallResponseEntity goodsSave(@RequestBody String goodsInfo);

    /**
     * 获取商品分类信息
     * @param id 分类id
     */
    @GetMapping("/adminApi/goods/goodsTypeInfo/{id}")
    MallResponseEntity<MallGoodsType> goodsTypeInfo(@PathVariable(value = "id") Long id);

    /**
     * 获取商品分类列表
     */
    @GetMapping("/adminApi/goods/goodsTypeList")
    MallResponseEntity<List<MallGoodsType>> goodsTypeList();

    /**
     * 获取商品分类列表
     * @param pid   父级分类id
     */
    @GetMapping("/adminApi/goods/goodsTypeList/{pid}")
    MallResponseEntity<List<MallGoodsType>> goodsTypeListWithParent(@PathVariable(value = "pid") Long pid);

}
